import numpy as np
import matplotlib.pyplot as plt

norm_conf = np.genfromtxt('confmat.csv', delimiter=',')

fig = plt.figure()
plt.clf()
ax = fig.add_subplot(111)
res = ax.imshow(np.array(norm_conf), cmap=plt.cm.Greys, 
                interpolation='nearest')

width = len(norm_conf)
height = len(norm_conf[0])
height = width

for x in xrange(width):
    for y in xrange(height):
        ax.annotate('.%(a)02d' % {"a": int(norm_conf[x][y]*100)}, xy=(y, x),
                    horizontalalignment='center',
                    verticalalignment='center',fontsize=20,color='w')
ss = plt.ylim()
print ss
alphabet = '12345678'
plt.xticks(range(width), alphabet[:width],fontsize=20)
plt.yticks(range(height), alphabet[:height],fontsize=20)
plt.ylim(7.5,-0.5)
plt.savefig('confusion_matrix.pdf', format='pdf')
